<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateStatusTables extends Migration
{
    protected $tablePrefix = 'kx_';

    public function __construct() {
        $tablePrefix = \Config::get('site-tables.tablePrefix');
        if ($tablePrefix) {
            $this->tablePrefix = $tablePrefix;
        }
    }

    protected function getTableName($tableName = ''){
        return $this->tablePrefix . \Config::get('site-tables.tableName.' . $tableName);
    }


    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (! Schema::hasTable($this->getTableName('status_original_data'))) {
            Schema::create( $this->getTableName('status_original_data'), function (Blueprint $table) {
                $table->increments('id');
                $table->string('platform')->default('cms')->comment('platform english name');
                $table->string('module')->default('default')->comment('module english name');
                $table->string('action')->default('default')->comment('action name');
                $table->string('url')->default('');
                $table->string('user_id')->default(0);
                $table->string('system', 30)->default('');
                $table->string('brower', 30)->default('');
                $table->string('device', 30)->default('');
                $table->string('user_agent')->default('');
                $table->string('ip_address')->default('');
                $table->dateTime('updated_at');
            });
        }
 
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
